from flask import Flask
from flask import render_template, request
import json

import pandas as pd
k_line = pd.read_csv('history_Index_k_data.csv',)

app = Flask(__name__,
            static_folder="./static", 
            static_url_path="")

@app.route('/testecharts')
def test_echarts():
    
    # process data
    tar_data = [5, 20, 36, 10, 10, 20]
    tar_data = sorted(tar_data)
    return render_template('test_echarts.html', tar_data=tar_data)

@app.route('/kline')
def test_kline():     
    date_list = k_line['date'].values.tolist()[-20:]
    tar_data = k_line[['open','close','low','high']].values.tolist()[-20:] 
    return render_template('k_line.html', date_list=date_list, tar_data=tar_data)


    

if __name__ == "__main__":
    app.run(host='0.0.0.0',port=5050)
